<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>line</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="limit.html" title="limit" />
    <link rel="next" href="linen.html" title="linen" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">line</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="limit.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="linen.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="line"></a>
      <div class="titlepage"></div>
      <a id="IndexLine" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">line</span>
        </h2>
        <p>line — 
      Trace a straight line between specified points.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118658192"></a>
        <h2>Description</h2>
        <p>
      Trace a straight line between specified points.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118728768"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>line</strong></span> ia, idur, ib</pre>
        <pre class="synopsis">kres <span class="command"><strong>line</strong></span> ia, idur, ib</pre>
      </div>
      <div class="refsect1">
        <a id="idp118732448"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ia</em></span> -- starting value.
    </p>
        <p>
      <span class="emphasis"><em>ib</em></span> -- value after <span class="emphasis"><em>idur</em></span> seconds.
    </p>
        <p>
      <span class="emphasis"><em>idur</em></span> -- duration in seconds of segment. A zero or negative value will cause all initialization to be skipped.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118736480"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>line</em></span> generates control or audio signals whose values move linearly from an initial value to a final one.
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        A common error with this opcode is to assume that the value of
        <span class="emphasis"><em>ib</em></span> is held after the time
        <span class="emphasis"><em>idur1</em></span>. <span class="emphasis"><em>line</em></span> does not
        automatically end or stop at the end of the duration given. If your
        note length is longer than <span class="emphasis"><em>idur</em></span> seconds,
        <span class="emphasis"><em>kres</em></span> (or <span class="emphasis"><em>ares</em></span>) will not come
        to rest at <span class="emphasis"><em>ib</em></span>, but will instead continue to rise
        or fall with the same rate. If a rise (or fall) and then hold is
        required that the <span class="emphasis"><em>linseg</em></span> opcode should be 
        considered instead.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp118743328"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the line opcode. It uses the file <a class="ulink" href="examples/line.csd" target="_top"><em class="citetitle">line.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp118745104"></a>
          <p class="title">
            <strong>Example 419. Example of the line opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac   <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o line.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1 

kp <span class="op">=</span> p6
<span class="comment">;choose between expon or line</span>
<span class="octrl">if</span> (kp <span class="op">==</span> 0) then 	
  kpitch <span class="opc">expon</span> p4, p3, p5 
<span class="octrl">elseif</span> (kp <span class="op">==</span> 1) then
  kpitch <span class="opc">line</span> p4, p3, p5 
<span class="octrl">endif</span>

asig   <span class="opc">vco2</span> .6, kpitch 
       <span class="opc">outs</span> asig, asig

<span class="oblock">endin</span> 
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
 

<span class="stamnt">i</span> 1 0  2 300  600  0	<span class="comment">;if p6=0 then expon is used</span>
<span class="stamnt">i</span> 1 3  2 300  600  1	<span class="comment">;if p6=1 then line is used</span>
<span class="stamnt">i</span> 1 6  2 600  1200 0
<span class="stamnt">i</span> 1 9  2 600  1200 1
<span class="stamnt">i</span> 1 12 2 1200 2400 0
<span class="stamnt">i</span> 1 15 2 1200 2400 1
<span class="stamnt">i</span> 1 18 2 2400 30   0
<span class="stamnt">i</span> 1 21 2 2400 30   1
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118749392"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="expon.html" title="expon"><em class="citetitle">expon</em></a>, 
      <a class="link" href="expseg.html" title="expseg"><em class="citetitle">expseg</em></a>, 
      <a class="link" href="expsegr.html" title="expsegr"><em class="citetitle">expsegr</em></a>, 
      <a class="link" href="linseg.html" title="linseg"><em class="citetitle">linseg</em></a>, 
      <a class="link" href="linsegr.html" title="linsegr"><em class="citetitle">linsegr</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118755344"></a>
        <h2>Credits</h2>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="limit.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="linen.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">limit </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> linen</td>
        </tr>
      </table>
    </div>
  </body>
</html>
